const mongoose = require('mongoose');
const { MONGODB_URI } = process.env;

const connectDB = async () => {
    try {
        // 移除不支持的选项
        const conn = await mongoose.connect(MONGODB_URI);

        console.log(`MongoDB 连接成功: ${conn.connection.host}`);
    } catch (error) {
        console.error(`数据库连接失败: ${error.message}`);
        process.exit(1);
    }
};

module.exports = connectDB;